<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.text.convert.Float</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.text.convert.Float");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461">tango.text.convert.Float</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Initial release: Nov 2005<br><br>
<b>author:</b><br>Kris<br><br>        A set of functions for converting between string and floating-
        point values.<br><br>        Applying the D "import alias" mechanism to this module is highly
        recommended, in order to limit namespace pollution:
        <pre class="d_code">

        <span class="k">import</span> <span class="i">Float</span> = <span class="i">tango</span>.<span class="i">text</span>.<span class="i">convert</span>.<span class="i">Float</span>;

        <span class="k">auto</span> <span class="i">f</span> = <span class="i">Float</span>.<span class="i">parse</span> (<span class="sl">"3.14159"</span>);
        
</pre><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>enum; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Constants
                
</font><br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>NumType <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L54">toFloat</a></span>
<script>explorer.outline.addDecl('toFloat');</script>(T)(T[] <span class="funcparam">src</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Convert a formatted string of digits to a floating-point
        number. Throws an exception where the input text is not
        parsable in its entirety.
        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L73">toString</a></span>
<script>explorer.outline.addDecl('toString');</script>(NumType <span class="funcparam">d</span>, uint <span class="funcparam">decimals</span> = Dec, int <span class="funcparam">e</span> = Exp);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Template wrapper to make life simpler. Returns a text version
        of the provided value.</font><br><br>
<font color="black">See format&#40;&#41; for details<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>wchar[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L89">toString16</a></span>
<script>explorer.outline.addDecl('toString16');</script>(NumType <span class="funcparam">d</span>, uint <span class="funcparam">decimals</span> = Dec, int <span class="funcparam">e</span> = Exp);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Template wrapper to make life simpler. Returns a text version
        of the provided value.</font><br><br>
<font color="black">See format&#40;&#41; for details<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>dchar[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L105">toString32</a></span>
<script>explorer.outline.addDecl('toString32');</script>(NumType <span class="funcparam">d</span>, uint <span class="funcparam">decimals</span> = Dec, int <span class="funcparam">e</span> = Exp);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Template wrapper to make life simpler. Returns a text version
        of the provided value.</font><br><br>
<font color="black">See format&#40;&#41; for details<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L133">format</a></span>
<script>explorer.outline.addDecl('format');</script>(T, D=double, U=uint)(T[] <span class="funcparam">dst</span>, D <span class="funcparam">x</span>, U <span class="funcparam">decimals</span> = Dec, int <span class="funcparam">e</span> = Exp);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Convert a float to a string. This produces pretty good results
        for the most part, though one should use David Gay's dtoa package
        for best accuracy.</font><br><br>
<font color="black">Note that the approach first normalizes a base10 mantissa, then
        pulls digits from the left side whilst emitting them &#40;rightward&#41;
        to the output.<br><br>        The e parameter controls the number of exponent places emitted, 
        and can thus control where the output switches to the scientific 
        notation. For example, setting e=2 for 0.01 or 10.0 would result
        in normal output. Whereas setting e=1 would result in both those
        values being rendered in scientific notation instead. Setting e
        to 0 forces that notation on for everything.<br><br>        </font><br><br>
<b>TODO:</b><br>this should be replaced, as it is not sufficiently accurate<br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>NumType <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L298">parse</a></span>
<script>explorer.outline.addDecl('parse');</script>(T)(T[] <span class="funcparam">src</span>, uint* <span class="funcparam">ate</span> = null);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Convert a formatted string of digits to a floating-point number.
        Good for general use, but use David Gay's dtoa package if serious
        rounding adjustments should be applied.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>T[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L392">truncate</a></span>
<script>explorer.outline.addDecl('truncate');</script>(T)(T[] <span class="funcparam">s</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Truncate trailing '0' and '.' from a string, such that 200.000 
        becomes 200, and 20.10 becomes 20.1</font><br><br>
<font color="black">Returns a potentially shorter slice of what you give it.<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>NumType <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/convert/Float.d?rev=3461#L419">pow10</a></span>
<script>explorer.outline.addDecl('pow10');</script>(uint <span class="funcparam">exp</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Internal function to convert an exponent specifier to a floating
        point value.</font><br><br></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2004 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sun Jun  8 17:12:57 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>